package com.lzy.controller;

import java.util.Arrays;
import java.util.Map;

import com.lzy.service.ISysPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.lzy.common.R;
import com.lzy.entity.SysPostEntity;

/**
 * 岗位信息表
 *
 * @author lyw
 * @email lyw@gmail.com
 * @date 2023-02-27 20:34:44
 */
@RestController
@RequestMapping("/syspost")
public class SysPostController {
    @Autowired
    private ISysPostService sysPostService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestBody SysPostEntity sysPostEntity){
        IPage<Map<String, Object>> list = sysPostService.selectPageList(sysPostEntity);
        return R.ok().put("page", list);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{postId}")
    // @RequiresPermissions(".:syspost:info")
    public R info(@PathVariable("postId") Long postId){
		SysPostEntity sysPost = sysPostService.getById(postId);

        return R.ok().put("sysPost", sysPost);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    // @RequiresPermissions(".:syspost:save")
    public R save(@RequestBody SysPostEntity sysPost){
		sysPostService.save(sysPost);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    // @RequiresPermissions(".:syspost:update")
    public R update(@RequestBody SysPostEntity sysPost){
		sysPostService.updateById(sysPost);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    // @RequiresPermissions(".:syspost:delete")
    public R delete(@RequestBody Long[] postIds){
		sysPostService.removeByIds(Arrays.asList(postIds));

        return R.ok();
    }

}
